<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <title>Title</title>
    <%@ include file="../include/css.jsp" %>
</head>
<body>

<div class="content-wrapper">

    <!-- Main content -->
    <section class="content">

        <!-- Default box -->
        <div class="box">
            <div class="box-header with-border">
                <h3 class="box-title">添加用户</h3>

                <div class="box-tools pull-right">
                    <button type="button" class="btn btn-box-tool" id="backBtn">
                        <i class="fa fa-plus"></i> 返回列表
                    </button>
                </div>
            </div>


            <div class="box-body">
                <form action="/user/add"  id="saveForm" method="post" enctype="multipart/form-data">
                    <span>${errorMessage}</span>
                    <div class="form-group">
                        <label>姓名</label>
                        <input type="text" name="name" class="form-control" value="${user.name}">
                    </div>
                    <div class="form-group">
                        <label>手机号</label>
                        <input type="text" name="mobile" class="form-control" value="${user.mobile}">
                    </div>
                    <div class="form-group">
                        <label>密码</label>
                        <input type="password" name="password" class="form-control" id="password">
                    </div>
                    <div class="form-group">
                        <label>密码</label>
                        <input type="password" name="password1" class="form-control" id="password1">
                    </div>
                    <div class="form-group">
                        <label>权限</label>
                        <input type="text" name="permissions" class="form-control" value="${user.permissions}" >
                    </div>
                    <button class="btn btn-primary" id="saveBtn">保存</button>
                </form>
            </div>



        </div>
        <!-- /.box -->

    </section>
    <!-- /.content -->
</div>

<script
        src="https://code.jquery.com/jquery-2.2.4.min.js"
        integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
        crossorigin="anonymous"></script>
<script src="/static/bootstrap/js/bootstrap.min.js"></script>
<%@ include file="../include/js.jsp"%>
<script>

    $(function () {

        $("#saveBtn").click(function () {
            $("#saveForm").submit();
        });

        $("#saveForm").validate({
            errorClass : 'text-danger',
            errorElement : 'span',
            rules : {
                name :{
                    "required" : true
                },
                mobile : {
                    "required" : true
                },
                password : {
                    "required" : true
                },
                password1 : {
                    "required" : true,
                    "equalTo":"#password"
                },
                permissions:{
                    "required" : true
                }
            },
            messages :{
                name :{
                    "required" : "必填项！"
                },
                 mobile:{
                    "required" : "必填项！"
                },
                password :{
                    "required" : "必填项！"
                },
                password1 :{
                    "required" : "必填项！",
                    "equalTo":"两次输入的密码不一致！"
                },
                permissions :{
                    "required" : "必填项！"
                }
            }
        })

    })
</script>
</body>
</html>

